package com.siwei.mes.entity.experiment;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.io.Serializable;
import java.util.Date;


/**
 * 抽样样品试验项目(ExperimentSampleTestProject)实体类
 *
 * @author linzi
 * @since 2023-12-31 20:37:11
 */
@Data
@Accessors(chain = true)
@Table(name = "pk_experiment_sample_test_project")
@ApiModel(value = "ExperimentSampleTestProject", description = "抽样样品试验项目")
public class ExperimentSampleTestProject implements Serializable {
    private static final long serialVersionUID = 795011317621836012L;
    /**
     * 主键id
     */
    @Id
    @ApiModelProperty(value = "抽样样品试验项目主键ID", name = "id")
    private Long id;

    /**
     * 1-水泥 2-粉煤灰 3-矿渣粉 4-粗骨料 5-细骨料 6-外加剂 7-混凝土
     */
    @Column(name = "experiment_type")
    @ApiModelProperty(value = "1-水泥 2-粉煤灰 3-矿渣粉 4-粗骨料 5-细骨料 6-外加剂 7-混凝土", name = "experimentType")
    private Integer experimentType;

    @Column(name = "freq_number")
    @ApiModelProperty(value = "执行频次")
    private Integer freqNumber;

    @Column(name = "freq_unit")
    @ApiModelProperty(value = "频次单位")
    private String freqUnit;

    /**
     * 样品试验项目code
     */
    @Column(name = "item_code")
    @ApiModelProperty(value = "样品试验项目code", name = "itemCode")
    private String itemCode;
    /**
     * 样品试验项目名称
     */
    @Column(name = "item_name")
    @ApiModelProperty(value = "样品试验项目名称", name = "itemName")
    private String itemName;
    /**
     * 对应试验类型
     */
    @Column(name = "test_type")
    @ApiModelProperty(value = "对应试验类型", name = "testType")
    private String testType;
    /**
     * 对应试验项目code
     */
    @Column(name = "test_code")
    @ApiModelProperty(value = "对应试验项目code", name = "testCode")
    private String testCode;
    /**
     * 对应试验项目名称
     */
    @Column(name = "test_name")
    @ApiModelProperty(value = "对应试验项目名称", name = "testName")
    private String testName;
    /**
     * 生成条数
     */
    @Column(name = "gen_number")
    @ApiModelProperty(value = "生成条数", name = "genNumber")
    private Integer genNumber;
    /**
     * 对应生成的json
     */
    @Column(name = "gen_json")
    @ApiModelProperty(value = "对应生成的json", name = "genJson")
    private JSONObject genJson;
    /**
     * 创建人
     */
    @Column(name = "creater")
    @ApiModelProperty(value = "创建人", name = "creater")
    private Long creater;
    /**
     * 创建时间
     */
    @Column(name = "create_time")
    @ApiModelProperty(value = "创建时间", name = "createTime")
    private Date createTime;
    /**
     * 修改人
     */
    @Column(name = "updater")
    @ApiModelProperty(value = "修改人", name = "updater")
    private Long updater;
    /**
     * 更新时间
     */
    @Column(name = "update_time")
    @ApiModelProperty(value = "更新时间", name = "updateTime")
    private Date updateTime;
    /**
     * 是否删除  1-删除
     */
    @Column(name = "is_del")
    @ApiModelProperty(value = "是否删除  1-删除", name = "isDel")
    private Integer isDel;
    /**
     * 是否启用  0-启用  1-未启用
     */
    @Column(name = "is_enable")
    @ApiModelProperty(value = "是否启用  0-启用  1-未启用 ", name = "isEnable")
    private Integer isEnable;

    /**
     * 是否是快检 1-是 0-不是
     */
    @Transient
    @ApiModelProperty(value = "是否是快检 1-是 0-不是", name = "isQuick")
    private Long isQuick;
    /**
     * 是否是批检  1-是  0-不是
     */
    @Transient
    @ApiModelProperty(value = "是否是批检  1-是  0-不是", name = "isBatch")
    private Long isBatch;

    /**
     * 组装对应的jsonArray
     *
     * @param genJson   jsonObject
     * @param genNumber 里面要几个
     * @return
     */
    public static JSONArray payloadJsonArray(JSONObject genJson, Integer genNumber) {
        if (genJson == null || genNumber == null || genNumber == 0) {
            return null;
        }
        JSONArray jsonArray = new JSONArray();
        for (int i = 0; i < genNumber; i++) {
            jsonArray.add(genJson);
        }
        return jsonArray;
    }
}
